package com.ruoyi.demo.service.sale.impl;

import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.demo.domain.DemoCustomer;
import com.ruoyi.demo.domain.DemoGoods;
import com.ruoyi.demo.service.base.DemoCustomerService;
import com.ruoyi.demo.service.base.DemoGoodsService;
import com.ruoyi.demo.service.sale.SaleService;
import com.ruoyi.demo.vo.GoodsCustomerVo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @description 销售
 * @author zhangshu
 * @date 2021/02/02 17:20
 * @version 1.0
 */
public class SaleServiceImpl implements SaleService {

    @Autowired
    private DemoGoodsService demoGoodsService;
    @Autowired
    private DemoCustomerService demoCustomerService;

    @Override
    public List<GoodsCustomerVo> queryList(GoodsCustomerVo goodsCustomerVo) {
        //商品
        DemoGoods demoGoods = new DemoGoods();
        //客户
        DemoCustomer demoCustomer = new DemoCustomer();
        //对象赋值
        BeanUtil.copyProperties(demoGoods, goodsCustomerVo);
        BeanUtil.copyProperties(demoGoods, demoCustomer);
        //demoGoodsService.queryList(demoGoods);
        //如果我查询的是客户手机号,那么只在DemoCustomer中才有,方法1使用代码实现:判断前端是否查询手机号
        //if (BeanUtil.isNotEmpty(demoCustomer,"customerId","customerName")) {
        //    //根据搜索条件查询出客户id
        //    List<DemoCustomer> demoCustomerList = demoCustomerService.queryList(demoCustomer);
        //    demoCustomerList.stream().map(demoCustomerStream -> {
        //        BeanUtil.copyProperties(demoCustomerStream, goodsCustomerVo);
        //        demoCustomerService.listByIds()
        //    })
        //}


        //商品集合
        //List<GoodsCustomerVo> collect= new ArrayList<GoodsCustomerVo>();
        ////如果前端没有查询者goodsCustomerVo为空,查询全部
        //if (BeanUtil.isEmpty(goodsCustomerVo)) {
        //    List<DemoGoods> list = demoGoodsService.list();
        //    collect = list.stream().map(demoGoods -> {
        //        BeanUtil.copyProperties(demoGoods, goodsCustomerVo);
        //        String customerName = demoCustomerService.getById(demoGoods.getCustomerId()).getCustomerName();
        //        goodsCustomerVo.setCustomerName(customerName);
        //        return goodsCustomerVo;
        //    }).collect(Collectors.toList());
        //}
        //DemoGoods demoGoods = new DemoGoods();
        //List<DemoGoods> demoGoodsList = demoGoodsService.queryList(demoGoods);
        //demoGoodsList.stream().map(demoGoods1 -> {
        //    String customerName = demoCustomerService.getById(demoGoods1.getCustomerId()).getCustomerName();
        //    goodsCustomerVo.se
        //});
        return null;
    }
}
